<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<input type="button" value="按钮1">
	<input type="button" value="按钮2">
	<input type="button" value="按钮3">
	<script type="text/javascript">
		var btn=document.getElementsByTagName("input");
		for(var i=0;i<btn.length;i++){
			btn[i].onclick=fn;
		}
		function fn(){
			this.style.backgroundColor="yellow";
		}
	</script>
</body>
</html>